#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    int ret = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> s;
        if (s[0] == s[2] && s[1] == s[3] - 1)
            ret++;
    }

    cout << ret;
    return 0;
}